package com.lfg.project.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lfg.project.common.ErrorCode;
import com.lfg.project.exception.BusinessException;
import com.lfg.project.model.entity.InterfaceInfo;
import com.lfg.project.model.entity.UserInterfaceInfo;
import com.lfg.project.service.UserInterfaceInfoService;
import com.lfg.project.mapper.UserInterfaceInfoMapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
 * @author liufaguang
 * @description 针对表【user_interface_info(用户调用接口关系)】的数据库操作Service实现
 * @createDate 2023-03-17 19:45:31
 */
@Service
public class UserInterfaceInfoServiceImpl extends ServiceImpl<UserInterfaceInfoMapper, UserInterfaceInfo>
        implements UserInterfaceInfoService {

    @Override
    public void validUserInterfaceInfo(UserInterfaceInfo interfaceInfo, boolean add) {
        if (interfaceInfo == null) {
            throw new BusinessException(ErrorCode.PARAMS_ERROR);
        }

        Long id = interfaceInfo.getUserId();
        Long interfaceInfoId = interfaceInfo.getInterfaceInfoId();
        Integer status = interfaceInfo.getStatus();
        Integer isDelete = interfaceInfo.getIsDelete();
        Integer leftNum = interfaceInfo.getLeftNum();
        Integer totalNum = interfaceInfo.getTotalNum();
        // 创建时，所有参数必须非空
        if (add) {
            if (id < 0) {
                throw new BusinessException(ErrorCode.PARAMS_ERROR);
            }
        }
//        if (StringUtils.isNotBlank(name) && name.length() > 50) {
//            throw new BusinessException(ErrorCode.PARAMS_ERROR, "内容过长");
//        }
    }
}




